<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<script src="../script/mui.min.js"></script>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../css/app.css" />
		<style type="text/css">
			body {
				color: #3E9FEC;
				background-color: #FFF;
			}
			.mui-bar-nav {
				-webkit-box-shadow: none;
				box-shadow: none;
			}
			.mui-bar {
				-webkit-box-shadow: none;
				box-shadow: none;
			}
			.wrong {
				color: #e02a53
			}
			.undo {
				color: #4fd2c2;
			}
			.item-col {
				width: 20%;
				float: left;
				margin-top: 15px;
				margin-bottom: 10px;
			}
			.item {
				background-color: #f0f0f0;
				width: 32px;
				height: 32px;
				font-size: 14px;
				line-height: 32px;
				text-align: center;
				border-radius: 16px;
				margin: 0px auto;
			}
			.itempad {
				/*margin-top: 80px;*/
				
				background-color: #30a4ed;
				padding: 20px 50px;
				/*float: left;*/
			}
			.itempad p {
				color: #fff;
				font-size: 15px;
			}
			.items-row {} .mui-btn-positive {
				background-color: #4fd2c2;
				border: 1px solid #4fd2c2;
			}
			.itempad2 {
				margin: 0 auto;
				width: 100%;
			}
			.itempad2 .items-row {
				padding: 50px 50px;
				background-color: #fff;
			}
			.itempad2 .items-row p {
				font-size: 15px;
				color: #30A4ED;
				text-align: center;
			}
			.questionpad {
				padding: 5px 50px;
			}
		</style>
	</head>

	<body>
		<div id="content">

		</div>
		<script type="text/html" id="resultTem">
			<div class="itempad">
				<div style="text-align: center;">
					<p>本次测试共答对 {{rightitemcount}} 道题</p>
					<p>得分:{{score}}分</p>
				</div>
			</div>
			<div class="questionpad">
				<div class="items">
					<div class="items-row" id="itemslist">
						{{each subdata}}
						<div class="item-col">
							<div class="item {{if $value.status=="wrong"}}wrong {{else if $value.status=="right"}}right {{else}}undo{{/if}}" data-status="{{if $value.status=="wrong"}}wrong{{else if $value.status=="right"}}right{{else}}undo{{/if}}">
								{{$index+1}}
							</div>
						</div>
						{{/each}}
					</div>
					<div class="clearfix"></div>
					<div class="items-row" style="width: 50%;margin: 25px auto;height: 50px;">
					</div>
				</div>
			</div>
			<div style="clear: both;"></div>
			<div class="itempad2">
				<div class="items-row">
					<p>试卷名称:{{papername}} </p>
					<p>批阅时间:{{$getLocalTime(checkedtime)}}</p>
				</div>
			</div>
		</script>
		<script src="../script/db.js" type="text/javascript" charset="utf-8"></script>
		<script src="../script/template.js" type="text/javascript" charset="utf-8"></script>
		<script src="../script/app.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			template.helper('$getLocalTime', function(nS) {
				var d = new Date(parseInt(nS) * 1000);
				var s = '';
				s += d.getFullYear() + '年';
				s += (d.getMonth() + 1) + '月';
				s += d.getDate() + '日 ';
				s += d.getHours() + ':';
				s += d.getMinutes();
				return s;
			});

			function loadResulst(data) {
				data.key = getUserKey();
				var url = MYAPP.webroot + "/api/index.php/Home/Index/getTestResult";
				api.ajax({
					url: url,
					method: 'post',
					timeout: 30,
					dataType: 'json',
					data: {
						values: data
					},
					returnAll: false
				}, function(ret, err) {
					if (ret.code = 200) {
						if (ret.status == "ok") {
							var html = template('resultTem', ret.data);
							document.getElementById("content").innerHTML = html;
						}
					} else {
						api.toast({
							msg: '错误码：' + err.code + '；错误信息：' + err.msg + '网络状态码：' + err.statusCode,
							location: 'middle',
							duration: 1000
						});
					}
				});
			}
			apiready = function() {
				var data = api.pageParam;
				loadResulst(data);
				var key = getUserKey();
				mui('#content').on('tap', 'div', function() {
					var status = this.getAttribute('data-status');
					if(status=="wrong"){
						var data1={
							testid:data.id,
							key:key,
							type:"wrong"
						}
						api.openWin({
							name: 'testanalysis',
							url: 'testanalysis.html',
							pageParam: data1
						});
					}
					if(status=="right"){
						var data1={
							testid:data.id,
							key:key
						}
						api.openWin({
							name: 'testanalysis',
							url: 'testanalysis.html',
							pageParam: data1
						});
					}
					if(status=="undo"){
						var data1={
							testid:data.id,
							key:key
						}
						api.openWin({
							name: 'testanalysis',
							url: 'testanalysis.html',
							pageParam: data1
						});
					}
				});
			};
		</script>
	</body>

</html>